
package results;

import move.Move;
import move.Pause;
import move.QuarterCircle;
import move.SemiCircle;
import move.TypeTrajectory;
import objects.MobileStation;

/**
 * Indicates the current path of a mobile station
 * 
 * @author Guillaume
 * @created June 8, 2004
 */

public class ProbeMoveCurrentPath extends ProbeMove {

	/** Property name monitored by the probe */
	private static final String PROPERTY_NAME = "ProbeMoveCurrentPath";

	/** Probe description */
	private static final String PROBE_DESCRIPTION = "";
	

	/**
	 * 
	 * @param t
	 * @param probeName probe name
	 */
	public ProbeMoveCurrentPath(MobileStation t,String probeName) {
		super(DEPL_LOOP, t, probeName);
	}

	/**
	 * Get the inforation (in xml) about the <code>current_path</code>.
	 * We remind you of the use this path : <br />
	 * A MobileStation moves considering
	 * this <code>current_path</code>. It gives information about the MobileStation movement
	 * such as the <code>ideal_speed </code>, the <code>real_speed</code>, the vector to move in the Space ...
	 * This method tries to gather all this information and present it as a xml String.
	 * 
	 * @see Move.Move
	 * @see Move.Pause
	 * @see Move.line
	 * @see Move.QuarterCircle
	 * @see Move.SemiCircle
	 * @see Results.Probe#getValue()
	 */
	protected Object getValue() {
		
		TypeTrajectory tt = ((MobileStation) _linkedStation).getCurrentPath();
		if (tt == null) return "ERROR";
		StringBuffer s = new StringBuffer("");
		
		// fetch the class name : can be Move.Pause, Move.Move ....
		s.append(tt.getClass().getName());
		
		// Pause or Move ?
		if (tt instanceof Pause){
			s.append("<property name=\"pauseDuration\" value=\""+  ((Pause )tt).getRestLength() + "\" />");
		
		// if it' s not Pause we know it is at least Move
		}else {
			Move ttLoc = ((Move) tt);
			s.append("<property name=\"coordX_dep\" value=\""  +  ttLoc.getCoordXDep() + "\" />");
			s.append("<property name=\"coordY_dep\" value=\""  +  ttLoc.getCoordYDep() + "\" />");
			s.append("<property name=\"coordX_arr\" value=\""  +  ttLoc.getCoordX()    + "\" />");
			s.append("<property name=\"coordY_arr\" value=\""  +  ttLoc.getCoordY()    + "\" />");
			s.append("<property name=\"ideal_speed\" value=\"" +  ttLoc.getSpeed()     + "\" />");
			if (tt instanceof QuarterCircle || tt instanceof SemiCircle){
				boolean rotation = (tt instanceof QuarterCircle) ? ((QuarterCircle) tt).getFeelRot() : ((SemiCircle) tt).getFeelRot();
				String strRotation = (rotation) ? "TRIGO" : "HORAIRE"; 
				// TODO trouver traduction pour HORAIRE
				s.append("<property name=\"rotation_direction\" value=\""+  strRotation + "\" />");
			}
		}
		
		return s;
	}

	/**
	 * Get the property Name
	 * @return property name
	 * @see Results.Probe#getPropertyName()
	 */
	public String getPropertyName() {
		return PROPERTY_NAME;
	}

	/**
	 * Get the descitption of the probe
	 * @return probe description
	 * @see Results.Probe#getProbeDescription()
	 */
	public String getProbeDescription() {
		return PROBE_DESCRIPTION;
	}

	public static void main(String[] args) {
	}
}
